import type { ColumnsType } from "@/components";
import { ElText } from "element-plus"
import { h } from "vue"

/** 是否管理员 */
export const IS_SUPER_MANAGER = new Map([
    [true, "是"],
    [false, "否"]
])

/** 启用状态 */
export const ENABLE_STATE = new Map([
    [true, "启用"],
    [false, "禁用"]
])

/** 表格配置 */
export const columns: ColumnsType[] = [
    {
        width: 100,
        label: "项目ID",
        prop: "AppId"
    },
    {
        width: 120,
        label: "管理员ID",
        prop: "Id"
    },
    {
        minWidth: 120,
        label: "管理员名称",
        prop: "Username"
    },
    {
        minWidth: 100,
        label: "是否超级管理员",
        prop: "IsSuperManager",
        formatter(row, column, cellValue, index) {
            return h(ElText, {
                type: cellValue ? 'primary' : 'danger'
            }, () => IS_SUPER_MANAGER.get(cellValue) ?? "未知")
        },
    },
    {
        minWidth: 100,
        label: "角色",
        prop: "RoleListName"
    },
    {
        width: 100,
        label: "是否启用",
        prop: "Enable",
        formatter(row, column, cellValue, index) {
            return h(ElText, {
                type: cellValue ? 'primary' : 'danger'
            }, () => ENABLE_STATE.get(cellValue) ?? "未知")
        },
    },
    {
        width: 160,
        label: "登录安全配置",
        prop: "LoginSecurityConfig",
        Slots: {
            default: "LoginSecurityConfig"
        }
    },
    {
        width: 140,
        label: "是否启用谷歌验证",
        prop: "EnableGoogleAuth",
        Slots: {
            default: "EnableGoogleAuth"
        }
    },
    {
        width: 160,
        label: "是否激活谷歌验证码",
        prop: "ActiveGoogleAuth",
        Slots: {
            default: "ActiveGoogleAuth"
        }
    },
    {
        width: 180,
        label: "创建时间",
        prop: "CreatedAt",
        DateFormat: true,
        sortable: true
    },
    {
        width: 180,
        label: "最后登录时间",
        prop: "UpdatedAt",
        DateFormat: true,
        sortable: true
    },
    {
        fixed: "right",
        width: "200",
        label: "操作",
        prop: "operation",
        Slots: {
            default: "operation"
        }
    }
]